package org.example.DesignPatterns.State;

/**
 * @description:
 * @author: farprt
 * @create: 2022-09-23 18:27
 **/
public class Yellow implements State{

    @Override
    public void switchToGreen(TrafficLight trafficLight) {
        System.out.println("绿灯亮起");
    }

    @Override
    public void switchToYellow(TrafficLight trafficLight) {
        trafficLight.setState(new Yellow());
        System.out.println("Error，已是黄灯，无需切换");
    }

    @Override
    public void switchToRed(TrafficLight trafficLight) {
        System.out.println("红灯亮起");
    }
}